<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
    );

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    //添加yy2-admin区域。有modules aliases
    'aliases' => [
          '@mdm/admin' => '@vendor/mdmsoft/yii2-admin',
    ],
    'modules' => [
            'admin' => [
                  'class' => 'mdm\admin\Module',
                  /*
                    'layout' => 'left-menu', // it can be '@path/to/your/layout'.
                    'controllerMap' => [
                        'assignment' => [
                                'class' => 'mdm\admin\controllers\AssignmentController',
                                'userClassName' => 'app\models\User',
                                'idField' => 'id'
                        ]
                    ],
                    'menus' => [
                    'assignment' => [
                            'label' => 'Grand Access' // change label
                        ],
                      //'route' => null, // disable menu route
                    ]
                    */
            ],
            'debug' => [
                'class' => 'yii\debug\Module',
            ],
    ],

    'components' => [
                //添加yy2-admin区域。 authManager i18n
            'authManager' => [
                  'class' => 'yii\rbac\DbManager', // or use 'yii\rbac\DbManager'
            ],
            /*
            'i18n' => [
                'translations' => [
                  '*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@app/messages', // if advanced application, set @frontend/messages
                    'sourceLanguage' => 'en',
                    'fileMap' => [
                      //'main' => 'main.php',
                    ],
                  ],
                ],
              ],
              */

    /*
        'user' => [
            'identityCookie' => [
                'name'     => '_backendIdentity',
                'path'     => '/admin',
                'httpOnly' => true,
            ],
        ],
        'session' => [
            'name' => 'BACKENDSESSID',
            'cookieParams' => [
                'httpOnly' => true,
                'path'     => '/admin',
            ],
        ],
        */
            'user' => [
                'identityClass' => 'backend\models\User',
                'enableAutoLogin' => true,
            ],

            'log' => [
                'traceLevel' => YII_DEBUG ? 3 : 0,
                'targets' => [
                    [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                    ],
                ],
            ],

            'errorHandler' => [
            'errorAction' => 'site/error',
            ],

            //入口移到根目录后专用
            'assetManager' => [
            'basePath' => '@webroot/backend/web/assets',
            'baseUrl' => '@web/backend/web/assets'
            ],

            'as access' => [
                'class' => 'mdm\admin\classes\AccessControl',
                'allowActions' => [
                    'site/*',
                    'admin/*',
                    'some-controller/some-action',
                    // The actions listed here will be allowed to everyone including guests.
                    // So, 'admin/*' should not appear here in the production, of course.
                    // But in the earlier stages of your development, you may probably want to
                    // add a lot of actions here until you finally completed setting up rbac,
                    // otherwise you may not even take a first step.
                ]
            ],
        ],

    'params' => $params,
];
